<!--
 * @Description: 
 * @Autor: 孙婧雯
 * @Date: 2021-07-04 14:45:31
 * @LastEditors: 孙婧雯
 * @LastEditTime: 2021-07-04 14:56:29
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input id="inpt1" value="请输入姓名" type="text">
  <script>
    var oInpt1 = document.getElementById('inpt1')
    oInpt1.onfocus = function () {
      if (this.value == '请输入姓名') {
        this.value = ''
      }
    }
    oInpt1.onblur = function () {
      if (this.value == '') {
        this.value = '请输入姓名'
      }
    }

  </script>
</body>

</html>